package com.tul.exercise.base.fanclass.eg1;

import com.tul.exercise.base.clazz.base.eg6.base.Cat;
import com.tul.exercise.base.clazz.base.eg6.base.Pet;

/**
 * @Description 《java编程思想》15 泛型.1 示例 2
 *  用泛型持特定类型
 *
 **/
public class Holder3<T> {
    private T obj;

    public Holder3(T obj) {
        this.obj = obj;
    }

    public T get() {
        return obj;
    }

    public void set(T obj) {
        this.obj = obj;
    }

    public static void main(String[] args) {
        Holder3<Automobile> aut = new Holder3<>(new Automobile());
        Automobile a = aut.get();

        Holder3<Pet> petHolder = new Holder3<>(new Pet());
        Pet p = petHolder.get();

        petHolder.set(new Cat());
        Pet c = petHolder.get();



    }





}
